//
//  HTNetworking.h
//  CreditCommunity
//
//  Created by maiya on 2017/10/12.
//  Copyright © 2017年 maiya. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>

typedef void ((^SuccessBlock)(id responseObject));
typedef void ((^FailureBlock)(id error));
typedef void ((^NetErrorBlock)(NSString *netError));

@interface HTNetworking : AFHTTPSessionManager

@property (nonatomic, copy) SuccessBlock successBlock;
@property (nonatomic, copy) FailureBlock failureBlock;
@property (nonatomic, copy) NetErrorBlock netErrorBlock;


//单利
+ (instancetype)sharedManager;

/**
 保存零时对象
 
 @param object Object
 */
- (void)addAPITool:(id)object;

/**
 删除对象

 @param object Object
 */
- (void)removeAPITool:(id)object;

/**
 获取网络状态
 
 AFNetworkReachabilityStatusUnknown          = -1,
 AFNetworkReachabilityStatusNotReachable     = 0,
 AFNetworkReachabilityStatusReachableViaWWAN = 1,
 AFNetworkReachabilityStatusReachableViaWiFi = 2,
 */

- (AFNetworkReachabilityStatus)networkReachabilityStatus;

/**
POST 网络请求
 
 @param url 请求接口
 @param parameters 请求参数
 @param successBlock 成功回调
 @param failureBlock 失败回调
 @param netErrorBlock 无网络回调
 */
- (void)POST:(NSString *)url parameters:(id)parameters success:(SuccessBlock)successBlock failure:(FailureBlock)failureBlock netError:(NetErrorBlock)netErrorBlock;

/**
 GET 网络请求
 
 @param url 请求接口
 @param parameters 请求参数
 @param successBlock 成功回调
 @param failureBlock 失败回调
 @param netErrorBlock 无网络回调
 */
- (void)GET:(NSString *)url parameters:(id)parameters success:(SuccessBlock)successBlock failure:(FailureBlock)failureBlock netError:(NetErrorBlock)netErrorBlock;


@end
